﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Inspired.Euler
{
    public static class Problem045
    {
        static void Main()
        {
            Func<long, long> t = n => n * (n + 1) / 2;
            Func<long, long> p = n => n * (3 * n - 1) / 2;
            Func<long, long> h = n => n * (2 * n - 1);

            Func<long, bool> isPentagonal = x => (Math.Sqrt(24 * x + 1) + 1) % 6 == 0;
            Func<long, bool> isHexagonal = x => (Math.Sqrt(8 * x + 1) + 1) % 4 == 0;

            Extensions.GetTriangle012()
                .Where(n => n > 40775)
                .First(x => isPentagonal(x) && isHexagonal(x))
                .DisplayAndPause();
        }
    }
}
